# Maintainer: Jaroslav Lichtblau <svetlemodry@archlinux.org>

pkgname=foremost
pkgver=1.5.7
pkgrel=6
pkgdesc="A console program to recover files based on their headers, footers, and internal data structures"
arch=('loong64' 'x86_64')
url="http://foremost.sourceforge.net/"
license=('custom')
depends=('glibc')
makedepends=('patch')
backup=(etc/foremost.conf)
source=(https://foremost.sourceforge.net/pkg/$pkgname-$pkgver.tar.gz
        $pkgname-makefile.patch
	$pkgname-1.5.7-fno-common.patch)
sha512sums=('8827c29d52496783be26374f3943eb26a154d842f34e50fb489f87b3a5045bf85f1e44d7d8d8b12b2355ba3fe4b06a0db979cc22c0f431593c5976001eb931ab'
            'eb3fc70590cafa3fb953946f6d80051ab3d976bcb3687cadb141a72dbd5bf317de68f39db7e28e27b49dd1629cab7e4c0ff5bc83c962c33026e9fe4d4ad2dc96'
            '4a129e0bb97f2c8aa09d6861077e732886e1d26573cc8698abfb03b55ebcf73c7ba1fbd6de25c5a4d2ce8cd271ebf07aa277d823d54640e6922ebc72a6aaba46')

prepare() {
  cd "${srcdir}"/$pkgname-$pkgver
  patch -Np0 -i "${srcdir}"/$pkgname-makefile.patch
  patch -Np1 -i "${srcdir}"/$pkgname-1.5.7-fno-common.patch
}

build() {
  cd "${srcdir}"/$pkgname-$pkgver
  make
}

package () {
  cd "${srcdir}"/$pkgname-$pkgver

  install -d "${pkgdir}"/{etc,usr/bin,usr/share/man/man8,usr/share/licenses/foremost}
  make DESTDIR="${pkgdir}" install

#license
  ./foremost -V > "${pkgdir}"/usr/share/licenses/$pkgname/COPYRIGHT
}
